﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.Services;
using System.Xml;
using System.Text;

namespace Bank.Account
{
    /// <summary>
    /// Service1 的摘要说明
    /// </summary>
    [WebService(Namespace = "mediinfo")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    public class BankAInter : System.Web.Services.WebService
    {
        [WebMethod]
        public string acc_query(decimal tradeno, string param)
        {
            string t;
            DataVisitor.calltrade(tradeno, param, out t);
            return t;
        }

        [WebMethod]
        public string acc_queryxml(string xmlparam)
        {
            var outxml = new StringBuilder();
            outxml.Append("<Response>");
            var xmldocument = new XmlDocument();
            xmldocument.LoadXml(xmlparam);
            var tradeno = xmldocument.SelectSingleNode("/Request/TranCode");
            var param = xmldocument.SelectSingleNode("/Request/InputParams");
            if (tradeno == null || param == null)
            {
                outxml.AppendFormat("<ReturnCode>-1</ReturnCode>");
                outxml.AppendFormat("<OutputParams>传入的xml参数不符合规范</OutputParams>");
            }
            else
            {
                string code, t;
                DataVisitor.calltrade(decimal.Parse(tradeno.InnerText), param.InnerText, out code, out t);
                outxml.AppendFormat("<ReturnCode>{0}</ReturnCode>", code);
                outxml.AppendFormat("<OutputParams>{0}</OutputParams>", t);
            }
            outxml.AppendFormat("</Response>");
            return outxml.ToString();
        }        
    }
}